import Vue from 'vue'
import Vuex from 'Vuex'
Vue.use(Vuex);
const module = localStorage.getItem('module');
const issus = localStorage.getItem('issus'); //期数
var userMsg = localStorage.getItem('userMsg')
const cut = localStorage.getItem('cut');
const typedt = localStorage.getItem('typedt') == null ? 1 : localStorage.getItem('typedt');

const store = new Vuex.Store({
    state: {
        userMsg: JSON.parse(userMsg), //用户信息的保存
        module: JSON.parse(module),
        cut: JSON.parse(cut),
        typedt: JSON.parse(typedt),
        showType: 1,
        issus: JSON.parse(issus)


    },
    mutations: {

        //保存用户信息
        getUserMsg(state, userMsg) {

            state.userMsg = JSON.parse(userMsg)

            localStorage.setItem('userMsg', userMsg)
        },
        typeid(state, typedt) {
            state.typedt = JSON.parse(typedt)
            localStorage.setItem('typedt', typedt)
        },
        //清空用户信息
        clearUserMsg() {
            localStorage.removeItem('userMsg')
        },
        getModule(state, module) {
            state.module = JSON.parse(module)
            localStorage.setItem('module', module)
        },
        getCut(state, cut) {
            state.cut = JSON.parse(cut)
            localStorage.setItem('cut', cut)
        },
        chaneShow(state, showType) {
            state.showType = showType
        },
        // 期数
        getNper(state, issus) {
            state.issus = JSON.parse(issus)
            localStorage.setItem('issus', issus)
        }


    },

})

export default store;